package com.rich.dmr.model;

import android.support.annotation.NonNull;

import java.math.BigDecimal;

public class ChannelModel {
    private int id;
    private String nameChannel;
    private int txChannel;
    private int rxChannel;
    private int colorCode;
    private int timeSlot;
    private int power;

    public ChannelModel(int id, String nameChannel, int txChannel, int rxChannel, int colorCode, int timeSlot, int power) {
        this.id = id;
        this.nameChannel = nameChannel;
        this.txChannel = txChannel;
        this.rxChannel = rxChannel;
        this.colorCode = colorCode;
        this.timeSlot = timeSlot;
        this.power = power;
    }

    public int getTimeSlot() {
        return timeSlot;
    }

    public void setTimeSlot(int timeSlot) {
        this.timeSlot = timeSlot;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public ChannelModel(int id, String nameChannel, int txChannel, int rxChannel) {
        this.id = id;
        this.nameChannel = nameChannel;
        this.txChannel = txChannel;
        this.rxChannel = rxChannel;
    }

    public int getColorCode() {
        return colorCode;
    }

    public void setColorCode(int colorCode) {
        this.colorCode = colorCode;
    }

    public ChannelModel(String nameChannel, int txChannel, int rxChannel) {
        this.nameChannel = nameChannel;
        this.txChannel = txChannel;
        this.rxChannel = rxChannel;
    }

    public String getNameChannel() {
        return nameChannel;
    }

    public void setNameChannel(String nameChannel) {
        this.nameChannel = nameChannel;
    }

    public int getTxChannel() {
        return txChannel;
    }

    public void setTxChannel(int txChannel) {
        this.txChannel = txChannel;
    }

    public int getRxChannel() {
        return rxChannel;
    }

    public void setRxChannel(int rxChannel) {
        this.rxChannel = rxChannel;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @NonNull
    @Override
    public String toString() {
        return "ReadFre:" + id +"/" + nameChannel + "/" + div(txChannel, 1000000) + "/" + div(rxChannel, 1000000);
    }

    private BigDecimal div(int v1, int v2) {
        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(Double.toString(v2));
        return b1.divide(b2, 4, BigDecimal.ROUND_HALF_UP);
    }
}
